import BaseFetch from "@/config/baseFetch";
import { APP_ID } from "@/config/index";


export interface Ilogin {
  code: string;
  jsCode?: string;
  referrer?: string;
}

export class UserApi extends BaseFetch {
  async autoLogin(code:string) {
    return await this.post(`/customer/account/wechatLogin`, {
      code,
      appId: APP_ID,
    });
  }
  async login(data: Ilogin) {
    return await this.post(`/customer/account/wechatPhoneNumberLogin`, {
      ...data,
      appId: APP_ID,
    })
  }
  async getUserInfo() {
    return await this.post(`/customer/account/getLoginUser`)
  }
  async updateUserInfo(userName: string|null,avatar:string|null,userRequests?:string[]|[]|null) {
    return await this.post(`/customer/account/updateUserBaseInfo`, {
      userName,
      avatar,
      userRequests
    });
  }
  async getAliYunUploadFile() {
    return await this.post(`/common/oss/generateUrl`, {
      businessCode: "user"
    });
  }
}
